package com.ry.servcie;

import com.ry.pojo.Cart;
import com.ry.pojo.CartTotal;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class TestCartImpl implements TestCart {
    @Override
    public CartTotal getCart() {
        List<Cart> list = new ArrayList<>();
        list.add(new Cart(100L,"/images/banner.jpg","titile1",100,100,"size1",10));
        list.add(new Cart(200L,"/images/banner.jpg","titile2",200,200,"size2",10));
        list.add(new Cart(300L,"/images/banner.jpg","titile3",300,300,"size3",10));
        list.add(new Cart(400L,"/images/banner.jpg","titile4",400,400,"size4",10));
        int total=0;
        for (Cart cart : list){
            total=total+cart.getPrice();
        }
        return new CartTotal(list,total);
    }
}
